package com.hb.trade.server.center.au.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hb.core.pojo.center.au.dto.OrgExtDTO;
import com.hb.core.pojo.center.au.entity.OrgDept;
import com.hb.core.pojo.center.au.mapper.OrgExtMapper;
import com.hb.core.pojo.center.au.entity.OrgExt;
import com.hb.trade.server.center.au.service.OrgExtService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 企业扩展信息 服务实现类
 * </p>
 *
 * @author zhaojk
 * @since 2021-11-29
 */
@Service
public class OrgExtServiceImpl extends ServiceImpl<OrgExtMapper, OrgExt> implements OrgExtService {

    /**
     *
     * @Description: 根据企业id查询企业扩展信息
     * @Author: zhongdl
     * @Date:2022/1/19 9:59
     * @param orgId:
     * @return: {@link OrgDept }
     **/
    @Override
    public OrgExt getOrgExtByOrgId(Long orgId) {
        QueryWrapper<OrgExt> wrapper = OrgExt.wrapper("id", "org_id", "district", "country",
                "reg_time", "valid_date", "credit_file", "capital", "econ_type", "org_type", "address_info",
                "address_detail", "org_phone", "postcode", "org_email", "fax", "com_address", "reg_author",
                "org_rules", "industry", "mana_scope", "bank_name", "bank_account", "bank_lic", "union_num",
                "tax_type", "tax_num", "invoice_head", "invoice_add", "invoice_tel", "invoice_bank",
                "invoice_bank_account", "tax_lic", "org_introduce", "create_id");
        wrapper.eq("org_id",orgId).last("limit 1");
        return getOne(wrapper);
    }

    @Override
    public boolean saveOrgExtDTO(OrgExtDTO orgExtDTO) {
        if (orgExtDTO == null){
            return false;
        }
        if (orgExtDTO.getId() == null){
            orgExtDTO.buildBaseData(1);
        }else {
            orgExtDTO.buildBaseData(2);
        }
        return saveOrUpdate(orgExtDTO);
    }


}
